# INSERT_YOUR_CODE

# Usage:
#   bash nohup_untar.sh file.tar
# 或
#   ./nohup_untar.sh file.tar

if [ $# -lt 1 ]; then
    echo "Usage: $0 file.tar[.gz|.bz2|.xz|.zst]"
    exit 1
fi

tarfile="$1"
logfile="$(basename "$tarfile").log"
outdir="$(basename "$tarfile" | sed 's/\.[^.]*$//')"

# 后台解压
nohup bash -c "
    mkdir -p \"$outdir\"
    tar -xf \"$tarfile\" -C \"$outdir\"
" > "$logfile" 2>&1 &

echo "Decompressing \"$tarfile\" into \"$outdir\" in background. Log: $logfile"
